"use client"; // 添加这一行，使组件变为 Client Component



import { useNodeMap } from "@/store/client/modules/reactdndStore/useNode";
import InputView from "./subassembly/input";
import ButtonView from "./subassembly/button";
import DraggableRowView from "./subassembly/grid/Row";
import DraggableColView from "./subassembly/grid/Col";

const SubassemblyView: React.FC<reactDndPropsId> = (props) => {
    const componentRegistry:any = {
        input: InputView,
        button: ButtonView,
        row: DraggableRowView,
        col: DraggableColView,
    };
    // 渲染时动态获取组件
    const { boxData, boxIndex } = useNodeMap()
    const Node = boxData.get(props.id)
    const Component = componentRegistry[Node.type];




    return <Component key={Node.id} data={Node} />;
}
export default SubassemblyView;